// n的阶乘1*2...n

/**
 * O(n)
 * @param {*} n 
 */
function factorial1(n){
    let res=1;
    for (let index = 2; index <= n; index++) {
       res*=index;
    }
    return res;
}

function factorial(n){
    if(n <2)return 1;
    return n*factorial(n-1)
}

3*2*1
console.log(factorial(3))

function factorial(n){
    if(n <1)return 1;
    return n*factorial(n-1)
}

3*2*1
console.log(factorial(3))